import type { RouteRecordRaw } from 'vue-router';
import { PageEnum } from '@/enums/pageEnum';
import { RootPage, LoginPage, NotFoundPage, MainPage, MusicDiscovery, Podcast, Video, Follow, PrivateRoaming, PlayList } from './constant';

export const RootPageRoute: RouteRecordRaw = {
  path: '/',
  redirect: PageEnum.BASE_MAIN,
  component: RootPage,
  // 请注意，只有子路由具有名称
  children: [
    {
      path: PageEnum.BASE_MAIN.replace('/', ''),
      name: PageEnum.BASE_MAIN_NAME,
      redirect: PageEnum.MENU_MUSIC_DISCOVERY,
      component: MainPage,
      children: [
        {
          path: PageEnum.MENU_MUSIC_DISCOVERY.replace('/main/', ''),
          name: PageEnum.MENU_MUSIC_DISCOVERY_NAME,
          component: MusicDiscovery,
          meta: {
            isKeepAlive: true,
            isMenu: true,
            realPath: PageEnum.MENU_MUSIC_DISCOVERY,
          },
        },
        {
          path: PageEnum.MENU_PODCAST.replace('/main/', ''),
          name: PageEnum.MENU_PODCAST_NAME,
          component: Podcast,
          meta: {
            isMenu: true,
            realPath: PageEnum.MENU_PODCAST,
          },
        },
        {
          path: PageEnum.MENU_VIDEO.replace('/main/', ''),
          name: PageEnum.MENU_VIDEO_NAME,
          component: Video,
          meta: {
            isMenu: true,
            realPath: PageEnum.MENU_VIDEO,
          },
        },
        {
          path: PageEnum.MENU_FOLLOW.replace('/main/', ''),
          name: PageEnum.MENU_FOLLOW_NAME,
          component: Follow,
          meta: {
            isMenu: true,
            realPath: PageEnum.MENU_FOLLOW,
          },
        },
        {
          path: PageEnum.MENU_PRIVATE_ROAMING.replace('/main/', ''),
          name: PageEnum.MENU_PRIVATE_ROAMING_NAME,
          component: PrivateRoaming,
          meta: {
            isMenu: true,
            realPath: PageEnum.MENU_PRIVATE_ROAMING,
          },
        },
        {
          path: PageEnum.MENU_PLAY_LIST.replace('/main/', ''),
          name: PageEnum.MENU_PLAY_LIST_NAME,
          component: PlayList,
          meta: {
            isMenu: true,
            realPath: PageEnum.MENU_PLAY_LIST,
          },
          props: true,
        },
      ],
      meta: {
        isKeepAlive: true,
        realPath: PageEnum.BASE_MAIN,
      },
    },
  ],
};

export const LoginRoute: RouteRecordRaw = {
  path: PageEnum.BASE_LOGIN,
  name: PageEnum.BASE_LOGIN_NAME,
  component: LoginPage,
  meta: {
    title: '登录',
  },
};

export const ErrorPageRoute: RouteRecordRaw = {
  path: '/:pathMatch(.*)*',
  redirect: { name: '404' },
};

export const NotFoundPageRoute: RouteRecordRaw = {
  path: '/404',
  name: '404',
  component: NotFoundPage,
};
